package net.shao.widget;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.LinearLayout;
import android.widget.TextView;

import net.shao.R;

/**
 * Created by shao on 2016/8/22.
 */
public class ChatListItemLongDialog extends Dialog {

    private ItemOnClick itemOnClick;

    public ChatListItemLongDialog(Context context) {
        this(context, 0);
        initView(context);
    }


    public ChatListItemLongDialog(Context context, int themeResId) {
        super(context, themeResId);
        initView(context);
    }

    private void initView(Context context) {
        View viewDialogItemLong = LayoutInflater.from(context).inflate(R.layout.view_dialog_chatlist,null);
        TextView tv_read_item = (TextView) viewDialogItemLong.findViewById(R.id.tv_tag_read_item_chatlist);
        TextView tv_top_item = (TextView) viewDialogItemLong.findViewById(R.id.tv_top_item_chatlist);
        TextView tv_remove_item = (TextView) viewDialogItemLong.findViewById(R.id.tv_remove_item_chatlist);

        tv_read_item.setOnClickListener(v -> {
            if (itemOnClick != null) {
                itemOnClick.onReadOnClick();
            }
        });

        tv_top_item.setOnClickListener(v -> {
            if (itemOnClick != null) {
                itemOnClick.onTopOnClick();
            }
        });

        tv_remove_item.setOnClickListener(v -> {
            if (itemOnClick != null) {
                itemOnClick.onRemoveClick();
            }
        });


        this.addContentView(viewDialogItemLong, new ViewGroup.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));

    }

    public interface ItemOnClick {
        void onReadOnClick();

        void onTopOnClick();

        void onRemoveClick();
    }

    public void setItemOnClick(ItemOnClick itemOnClick) {
        this.itemOnClick = itemOnClick;
    }
}
